home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR02 / DCGAMES1.ZIP / NEWGAME.ZIP / CASTING.SCR < prev    next >
Text File  |  1993-04-01  |  13KB  |  449 lines

  1. !
  2. ! CASTING.SCR - Spell Casting script
  3. !
  4. ! This script implements spell casting for wizards and elves.
  5. !
  6. ! (c) DC Software, 1992
  7. !
  8. ! Pending Enhancements
  9. !
  10. ! - This script has no voices.  For an example of voices, look at
  11. !   MERCHANT.SCR and HEALER.SCR.  Also, look at the OBJECT.SCR for
  12. !   the sounds that are used for type 1 magic (heal,cure,resurect,
  13. !   etc).  The same kind of sound applies here.
  14. !
  15. ! - This entire set of code is currently duplicated in the OBJECT.SCR
  16. !   file, since type 2 magic can be invoked by both a magic user (casting
  17. !   a spell) or by using an object (Scrolls and Staffs).  I need a 
  18. !   method for writing the script once and including it in two other
  19. !   places.
  20. !
  21.  
  22. :@CAST
  23.  
  24. if player.class <> WIZARD and player.class <> ELF then
  25.   writeln( player.name, " does not have magical abilities." );
  26.   STOP;
  27. endif;
  28.  
  29. if player.pwr <= 0 then
  30.   writeln( player.name, " has no power left.." );
  31.   STOP;
  32. endif;
  33.  
  34. if fighting then
  35.   L0 = select( "Kill", 20, "Confuse", 1, "Scare", 2, "Damage", 5, "Paralyze", 5 );
  36.   on L0 goto X_KILL, X_CONFUSE, X_SCARE, X_DAMAGE, X_PARALYZE;
  37. else
  38.   L0 = select( "Destroy",       5,
  39.                "Duplicate",    40,
  40.                "Leave",         5,
  41.                "Resurrect",    50,
  42.                "Inform",        5,
  43.                "Locate Doors", 10,
  44.                "Recharge",     25,
  45.                "Float",        10,
  46.                "Analyze",      10,
  47.                "View",         10 );
  48.   on L0 goto X_DESTROY, X_DUPLICATE, X_LEAVE, X_RESURRECT, X_INFORM,
  49.              X_LOCATE, X_RECHARGE,  X_FLOAT, X_ANALYZE,   X_ZOOM;
  50. endif;
  51.  
  52. writeln( "Ok." );
  53. STOP;
  54.  
  55. :X_DESTROY  
  56.   L0 = DESTROY;   L1 = 5;  L2 = 10;
  57.   gosub X_TARGET; goto X_DOIT;
  58.  
  59. :X_DUPLICATE
  60.   L0 = DUPLICATE; L1 = 40; L2 = 1;
  61.   gosub X_TARGET; goto X_DOIT;
  62.  
  63. :X_LEAVE  
  64.   L0 = LEAVE; L1 = 5;
  65.   goto X_DOIT;
  66.  
  67. :X_RESURRECT
  68.   L0 = RESURRECT; L1 = 50;
  69.   goto X_DOIT;
  70.  
  71. :X_INFORM  
  72.   L0 = INFORM; L1 = 5;
  73.   goto X_DOIT;
  74.  
  75. :X_LOCATE 
  76.   L0 = DOORS; L1 = 10;
  77.   goto X_DOIT;
  78.  
  79. :X_KILL  
  80.   L0 = KILL;    L1 = 20; L2 = 6;
  81.   gosub X_TARGET; goto X_DOIT;
  82.  
  83. :X_CONFUSE  
  84.   L0 = CONFUSE; L1 =  1;
  85.   goto X_DOIT;
  86.  
  87. :X_SCARE  
  88.   L0 = SCARE;   L1 =  2;
  89.   goto X_DOIT;
  90.  
  91. :X_DAMAGE  
  92.   L0 = DAMAGE;  L1 =  5;
  93.   goto X_DOIT;
  94.  
  95. :X_PARALYZE
  96.   L0 = PARALYZE; L1 = 5;
  97.   goto X_DOIT;
  98.  
  99. :X_RECHARGE
  100.   L0 = RECHARGE; L1 = 25; L2 = 1;
  101.   gosub X_TARGET; goto X_DOIT;
  102.  
  103. :X_FLOAT  
  104.   L0 = FLOAT; L1 = 10; L2 = 1;
  105.   gosub X_TARGET; goto X_DOIT;
  106.  
  107. :X_ANALYZE  
  108.   L0 = ANALYZE; L1 = 10; L2 = 1; 
  109.   gosub X_TARGET; goto X_DOIT;
  110.  
  111. :X_ZOOM  
  112.   L0 = ZOOM; L1= 10;
  113.   goto X_DOIT;
  114.  
  115. :X_DOIT
  116.   if player.pwr < L1 then
  117.     writeln( player.name, " doesn't have enough power.." );
  118.     STOP;
  119.   endif;
  120.  
  121.   dec( player.pwr, L1 );
  122.  
  123.   if L0 = DAMAGE or L0 = CONFUSE or L0 = SCARE or L0 = PARALYZE then
  124.     !
  125.     ! These spells operate on EVERY monster
  126.     !
  127.     ! L5 will contain the TOTAL experience points gained when done..
  128.     ! L6 is the maximum damage that will be done to a single monster..
  129.     ! L8 is the maximum total damage that can be done to a group of monsters..
  130.     ! L9 is the number of monsters affected..
  131.     !
  132.     L5 = 0;
  133.     L6 = player.level + adjustments(player.pwr) / 2 + 1;
  134.     if L6 <= 0 then
  135.       writeln( "The spell failed.." );
  136.       STOP;
  137.     endif;
  138.     L8 = player.iq;
  139.     L9 = 0;
  140.   endif;
  141.  
  142.   on L0 goto 
  143.     M2_NONE,     M2_DESTROY,  M2_DUPLICATE, M2_LEAVE,
  144.     M2_RESURRECT,M2_INFORM,   M2_LOCATE,    M2_KILL, 
  145.     M2_CONFUSE,  M2_SCARE,    M2_DAMAGE,    M2_PARALYZE,
  146.     M2_RECHARGE, M2_FLOAT,    M2_ANALYZE,   M2_ZOOM;
  147.  
  148. :M2_NONE      ! No spell
  149.   writeln( "Nothing happens.." );
  150.   STOP;
  151.  
  152. :M2_DESTROY   ! Destroy an object
  153.   writeln( "The ", object.type, " is destroyed.." );
  154.   vanish( object );
  155.   STOP;
  156.  
  157. :M2_DUPLICATE ! Duplicates an object
  158.   writeln( "The ", object.type, " has been duplicated.. " );
  159.   inc( object.count, 1 ); ! Creates an identical copy ! 
  160.   STOP;
  161.  
  162. :M2_LEAVE     ! Exit through the 'exit' door from anywhere...  
  163.   if world.type <> DUNGEON then
  164.     writeln( "This spell only work's in dungeons.." );
  165.     STOP;
  166.   endif;
  167.   enter( world.edgedoor );
  168.   writeln( "You leave this level of the dungeon.." );
  169.   STOP;
  170.  
  171. :M2_RESURRECT ! Revive a DEAD person                   
  172.   write( "Resurrect: " );
  173.   L3 = select( group );
  174.   if player.hp > 0 then
  175.     writeln( player.name, " is not dead!  The spell fails." );
  176.   else
  177.     writeln( player.name );
  178.     player.hp = 2;
  179.     writeln( player.name, " is alive, but weak.." );
  180.   endif;
  181.   STOP;
  182.  
  183. :M2_INFORM    ! Displays some text                     
  184.   loadhint;
  185.   writeln( "The wind seems to carry a random phrase to your ears.." );
  186.   writeln( s0 );
  187.   STOP;
  188.  
  189. :M2_LOCATE    ! Locate doors                           
  190.   for L5 = 0 to 15 do
  191.     if world.doorx(L5) > 0 and world.doory(L5) > 0 then
  192.       frame( world.doorx(L5), world.doory(L5), SYS_FRAME );
  193.     endif;
  194.   endfor;
  195.   STOP;
  196.  
  197. :M2_KILL      ! Kill 1 enemy during battle             
  198.   writeln( npc.name, " killed. +", npc.hp, " exp." );
  199.   inc( player.exp, npc.hp );
  200.   npc.hp = 0;
  201.   STOP;
  202.  
  203. :M2_DAMAGE    ! Causes damage to monsters              
  204.   S0 = "hit";
  205.   foreach npc do
  206.     L7 = min( npc.hp, random(L6) );  ! How much damage to this one monster?
  207.     if L7 > 0 then
  208.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  209.       write( npc.name );
  210.       if L7 < npc.hp then
  211.         write( " hit." );
  212.         dec( npc.hp, L7 );           ! Hit the monster..
  213.       else
  214.         write( " killed!" );
  215.         npc.hp = 0;
  216.       endif;
  217.       writeln( " +", L7, " exp." );
  218.       inc(L9);                       ! Count of affected npcs
  219.       inc( L5, L7 );                 ! Accumulate experience..
  220.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  221.     endif;
  222.   endfor;  
  223.   goto DCSPEXIT;
  224.  
  225. :M2_CONFUSE   ! Makes monsters shoot at other monsters 
  226.   S0 = "confused";
  227.   foreach npc do
  228.     L7 = min( npc.hp, random(L6) );  ! How much confusion to this one monster?
  229.     if L7 > 0 and npc.confused = 0 then
  230.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  231.       inc(L9);                       ! Count of affected npcs
  232.       npc.confused = L7;             ! Confuse for 'n' units
  233.       inc( L5, L7 );                 ! Accumulate experience..
  234.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  235.     endif;
  236.   endfor;  
  237.   goto DCSPEXIT;
  238.  
  239. :M2_SCARE     ! Scares monsters                        
  240.   S0 = "scared";
  241.   foreach npc do
  242.     L7 = min( npc.hp, random(L6) );  ! How much 'fright' to this one monster?
  243.     if L7 > 0 and npc.scared = 0 then
  244.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  245.       inc(L9);
  246.       npc.scared = L7;               ! Frighten for 'n' units
  247.       inc( L5, L7 );                 ! Accumulate experience..
  248.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  249.     endif;
  250.   endfor;  
  251.   goto DCSPEXIT;
  252.  
  253. :M2_PARALYZE  ! Monster can't move                     
  254.   S0 = "paralyzed";
  255.   foreach npc do
  256.     L7 = min( npc.hp, random(L6) );  ! How much paralysis to this one monster?
  257.     if L7 > 0 and npc.paralyzed = 0 then
  258.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  259.       inc(L9);
  260.       npc.paralyzed = L7;            ! Paralyze for 'n' units
  261.       inc( L5, L7 );                 ! Accumulate experience..
  262.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  263.     endif;
  264.   endfor;  
  265.   goto DCSPEXIT;
  266.  
  267. :M2_RECHARGE  ! Recharge an ITEM                       pwr = 25, rng=1
  268.   if object.type = RING or object.type = AMULET or object.type = STAFF then
  269.     inc( object.charges, random(player.level)+1 );
  270.     writeln( "The ", object.type, " now has ", object.charges, " charges." );
  271.   else
  272.     writeln( "The smell of rotten eggs fills the air.." );
  273.   endif;
  274.   STOP;
  275.  
  276. :M2_FLOAT     ! Remove an object's weight              pwr = 10, rng=1
  277.   if object.weight < 255 then
  278.     object.weight = object.weight / 2 + 1;
  279.     writeln( "The ", object.type, " is now much lighter.." );
  280.   else
  281.     writeln( "It's didn't work.  The ", object.type, " is too heavy." );
  282.   endif;
  283.   STOP;
  284.  
  285. :M2_ANALYZE   ! Discover object's properties           pwr = 10, rng=1
  286.   if npc.count then ! It's a character we cast this thing on..
  287.     writeln( npc.name, ", ", npc.class, ", Lvl ", npc.level,
  288.              ", AC ", npc.ac, ", HP ", npc.hp );
  289.   else
  290.     gosub ODETAIL;
  291.   endif;
  292.     STOP;
  293.  
  294. :M2_ZOOM      ! View the world.. 
  295.   viewpcx( world );
  296.   if success then
  297.     pause;
  298.   endif;
  299.   paint( screen );
  300.   STOP;
  301.  
  302.  
  303. !
  304. ! Award experience points (if any)
  305. !
  306. :DCSPEXIT
  307.   if L9 then
  308.     write( L9, " foes were ", S0 );
  309.     if L5 then  
  310.       writeln( " for a total of +", L5, " experience!" );
  311.       inc( player.exp, L5 );           ! Grant experience..
  312.     else
  313.       writeln( " With no effect" );
  314.     endif;
  315.   else
  316.     writeln( "No effect.." );
  317.   endif;
  318.   STOP;
  319.  
  320. !
  321. ! SUBROUTINE: X_TARGET
  322. !
  323. ! Selects a target to cast the spell on
  324. !
  325. :X_TARGET
  326.   write( s0, " what:" );
  327.   L3 = locate;               ! Identify an object or character to cast on !
  328.   if failure then
  329.     writeln( "nothing.." );
  330.     STOP;
  331.   endif;
  332.   if L3 > L2 then
  333.     writeln( "You must get closer.." );
  334.     STOP;
  335.   endif;
  336.   if npc.count then ! It's a character, not an object..
  337.     if npc.type = HOSTILE then
  338.       writeln( npc.name );  ! Monster's class is type of terrain mobility !
  339.     else
  340.       writeln( npc.class ); ! Human, elf, dwarf, etc..       !
  341.     endif;
  342.     if L0 = DESTROY  or L0 = DUPLICATE or
  343.        L0 = RECHARGE or L0 = FLOAT then
  344.       writeln( "This spell only work's on objects!" );
  345.       STOP;
  346.     endif;
  347.   else
  348.     writeln( object.type );  ! Food, weapon, ring, etc..      !
  349.   endif;
  350.   return;
  351.  
  352. !
  353. ! SUBROUTINE: ODETAIL
  354. !
  355. ! Display an object's detailed analysis
  356. !
  357. :ODETAIL
  358.   write( "Name: ", object.name );
  359.   write( ", Type: ", object.type );
  360.   if object.type = FOOD or object.type = POTION  then
  361.     if object.class then
  362.       write( ", Class: ", object.class );
  363.       if object.class <> CURE then
  364.         write( ", Units: ", object.units );
  365.       endif;
  366.     endif;
  367.   elsif object.type = WEAPON then
  368.     write( "Class: ", object.class, 
  369.            ", Hands: ", object.hands, 
  370.            ", Range: ", object.range, 
  371.            ", Damage: ", object.damage );
  372.     if object.ammoneeded then
  373.       write( ", Needs ammo type: ", object.ammo_type );
  374.     endif;
  375.   elsif object.type = AMMO then
  376.     write( "Ammo Type: ", object.ammotype );
  377.     if object.traptype then
  378.       write( ", Poisoned" );
  379.     endif;
  380.     if object.damage then
  381.       write( ", Extra Damage: ", object.damage );
  382.     endif;
  383.   elsif object.type = ARMOR or object.type = SHIELD then
  384.     write( "Armor Class: ", object.ac );
  385.     if object.cursed then
  386.       write( " Cursed!" );
  387.     endif;
  388.   elsif object.type = AMULET or object.type = RING or object.type = GEMS then
  389.     if object.class then
  390.       write( "Class: ", object.class );
  391.       write( ", Charges: ", object.charges );
  392.       if object.class <> CURE then
  393.         write( ", Units: ", object.units );
  394.         if object.permanent then
  395.           write( ", Permanent!" );
  396.         else
  397.           write( ", Temporary" );
  398.         endif;
  399.       endif;
  400.       if object.cursed then
  401.         write( ", Cursed!" );
  402.       endif;
  403.     endif;
  404.   elsif object.type = SCROLL then
  405.     write( "Class: ", object.class );
  406.   elsif object.type = STAFF then
  407.     write( "Class: ", object.class, ", Charges: ", object.charges );
  408.   elsif object.type = CHEST then
  409.     if object.locktype then
  410.       write( "Locked!" );
  411.       if object.traptype = 0 then
  412.         write( ", no traps" );
  413.       elsif object.traptype = 1 then
  414.         write( ", poison trap" );
  415.       else
  416.         write( ", bomb damage: ", object.traptype );
  417.       endif;
  418.     endif;
  419. ! elsif object.type = KEYS     then
  420. !   nothing special about it
  421. ! elsif object.type = BOOK     then
  422. !   nothing special about it
  423. ! elsif object.type = GOLDSACK then
  424. !   nothing special about it
  425. ! elsif object.type = TORCH    then
  426. !   nothing special about it
  427. ! elsif object.type = LANTERN  then
  428. !   nothing special about it
  429. ! elsif object.type = ROPE     then
  430. !   nothing special about it
  431. ! elsif object.type = HOOKS    then
  432. !   nothing special about it
  433. ! elsif object.type = MIRROR   then
  434. !   nothing special about it
  435. ! elsif object.type = SIGN     then
  436. !   nothing special about it
  437.   elsif object.type = VEHICLE then
  438.     write( "Class: ", object.class );
  439. ! else
  440. !   user defined type?
  441.   endif;
  442.   if object.weight > 1 and object.weight < 256 then
  443.     write( ", Weight: ", object.weight );
  444.   endif;
  445.   if object.count > 1 then
  446.     write( ", Count: ", object.count );
  447.   endif;
  448.   return;
  449.